<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>编辑收货地址 - 花间村</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <style>
        body { 
            background: #f5f5f5; 
            margin: 0; 
            font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif; 
            padding-bottom: 60px;
        }
        .container { 
            max-width: 100%; 
            padding: 15px; 
        }
        .page-title { 
            font-size: 20px; 
            font-weight: 600; 
            margin-bottom: 20px; 
            text-align: center; 
        }
        .form-group {
            margin-bottom: 20px;
        }
        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: 500;
        }
        .form-control {
            width: 100%;
            padding: 12px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 16px;
            box-sizing: border-box;
        }
        .submit-btn {
            display: block; 
            width: 100%; 
            background: #07C160; 
            color: #fff; 
            border: none;
            border-radius: 25px; 
            padding: 12px 0; 
            font-size: 16px; 
            margin-top: 30px; 
            cursor: pointer;
        }
        .default-btn {
            display: block; 
            width: 100%; 
            background: #1890ff; 
            color: #fff; 
            border: none;
            border-radius: 25px; 
            padding: 12px 0; 
            font-size: 16px; 
            margin-top: 10px; 
            cursor: pointer;
        }
        .cancel-btn {
            display: block; 
            width: 100%; 
            background: #f5f5f5; 
            color: #666; 
            border: 1px solid #ddd;
            border-radius: 25px; 
            padding: 12px 0; 
            font-size: 16px; 
            margin-top: 10px; 
            text-align: center;
            text-decoration: none;
        }
        .delete-btn {
            display: block; 
            width: 100%; 
            background: #ff4d4f; 
            color: #fff; 
            border: none;
            border-radius: 25px; 
            padding: 12px 0; 
            font-size: 16px; 
            margin-top: 10px; 
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="page-title">编辑收货地址</div>
        
        <form method="POST" action="{{ route('wechat.service.account.addresses.update', $address->id) }}">
            @csrf
            @method('PUT')
            <div class="form-group">
                <label for="consignee">收货人</label>
                <input type="text" id="consignee" name="consignee" class="form-control" value="{{ old('consignee', $address->consignee) }}" required>
            </div>
            
            <div class="form-group">
                <label for="mobile">手机号</label>
                <input type="text" id="mobile" name="mobile" class="form-control" value="{{ old('mobile', $address->mobile) }}" required>
            </div>
            
            <div class="form-group">
                <label for="province">省</label>
                <input type="text" id="province" name="province" class="form-control" value="{{ old('province', $address->province) }}" required>
            </div>
            
            <div class="form-group">
                <label for="city">市</label>
                <input type="text" id="city" name="city" class="form-control" value="{{ old('city', $address->city) }}" required>
            </div>
            
            <div class="form-group">
                <label for="district">区/县</label>
                <input type="text" id="district" name="district" class="form-control" value="{{ old('district', $address->district) }}">
            </div>
            
            <div class="form-group">
                <label for="address">详细地址</label>
                <input type="text" id="address" name="address" class="form-control" value="{{ old('address', $address->address) }}" required>
            </div>
            
            <button type="submit" class="submit-btn">更新地址</button>
        </form>
        
        @if(!$address->is_default)
        <form method="POST" action="{{ route('wechat.service.account.addresses.set-default', $address->id) }}" onsubmit="return confirm('确定要将此地址设为默认地址吗？');">
            @csrf
            <button type="submit" class="default-btn">设为默认地址</button>
        </form>
        @else
        <div style="text-align: center; color: #07C160; margin: 10px 0; font-size: 14px;">当前地址已是默认地址</div>
        @endif
        
        <form method="POST" action="{{ route('wechat.service.account.addresses.destroy', $address->id) }}" onsubmit="return confirm('确定要删除这个地址吗？');">
            @csrf
            @method('DELETE')
            <button type="submit" class="delete-btn">删除地址</button>
        </form>
        
        <a href="{{ route('wechat.service.account.addresses') }}" class="cancel-btn">取消</a>
    </div>
</body>
</html>